#
# Copyright (C) 2006,2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=oauth
PKG_VERSION:=1.2.1
PKG_RELEASE=2


PKG_LICENSE:=GPL-2.0
# Note: Packaging is maintained upstream at
# https://github.com/wifidog/packages
PKG_MAINTAINER:=Michael Haas <haas@computerlinguist.org>
PKG_LICENSE_FILES:=COPYING


PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://git.oschina.net/fenggui321/wifidog-wechat.git
#PKG_SOURCE_URL:=git://github.com/wifidog/wifidog-gateway.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=6c41d53bd24eac491dc2998ab805b69e9b18029e
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

PKG_FIXUP:=autoreconf
# do not run make install
PKG_INSTALL:=0
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk

define Package/oauth
  SUBMENU:=Captive Portals
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+iptables-mod-extra +iptables-mod-ipopt +iptables-mod-nat-extra +libpthread +libjson-c +libcyassl
  TITLE:=A wireless captive portal solution(customization)
  URL:=http://www.wifidog.org
endef

define Package/oauth/description
	OAuth:Modify wifidog for wechat wifi.The wididog project is
	a complete and embeddable captive portal solution for wireless
	community groups or individuals	who wish to open a free Hotspot 
	while still preventing abuse of their Internet connection.
endef

define Package/oauth/conffiles
/etc/wifidog.conf
endef

define Package/wifidog/configure
	$(call Build/Configure/Default)
endef

CONFIGURE_ARGS += \
  --enable-cyassl

define Package/oauth/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/wifidog $(1)/usr/bin/oauth
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/wdctl $(1)/usr/bin/
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libhttpd.so* $(1)/usr/lib/
	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_DATA) $(PKG_BUILD_DIR)/wifidog-msg.html $(1)/etc/oauth-msg.html
	$(INSTALL_DATA) $(PKG_BUILD_DIR)/wifidog.conf $(1)/etc/oauth.conf
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/oauth.init $(1)/etc/init.d/oauth
endef

$(eval $(call BuildPackage,oauth))
